package com.gohome.gohomechat.ui.activity;

import android.graphics.Bitmap;
import android.widget.ImageView;
import android.widget.TextView;

import com.gohome.gohomechat.GoHomeHelper;
import com.gohome.gohomechat.GoHomeModel;
import com.gohome.gohomechat.R;
import com.gohome.gohomechat.utils.CreateQRCode;

/**
 * Created by dllo on 16/3/14.
 */
public class MyQRCodeActivity extends BaseActivity{
    private TextView myqr_username;
    private ImageView myqr_qrcode;
    @Override
    protected int getLayout() {
        return R.layout.activity_myqrcode;
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    protected void initView() {
        myqr_username=findView(R.id.myqr_username);
        myqr_qrcode=findView(R.id.myqr_qrcode);
    }

    @Override
    protected void initData() {
        myqr_username.setText(GoHomeModel.getInstance().getCurrentUserName());
        createQRImage(GoHomeModel.getInstance().getCurrentUserName());
    }
    private void createQRImage(String content) {
        CreateQRCode.createQRImage(content, "test", new CreateQRCode.OnCreateQRListener() {
            @Override
            public void onSuccess(Bitmap qrImage) {
                myqr_qrcode.setImageBitmap(qrImage);
            }
        });
    }
}
